bitkeeper revision 1.593.1.1 (3fb2673ecxanxs8T80yNhChH3vMCyA)
authorbr260@labyrinth.cl.cam.ac.uk <br260@labyrinth.cl.cam.ac.uk>
Wed, 12 Nov 2003 17:00:46 +0000 (17:00 +0000)
committerbr260@labyrinth.cl.cam.ac.uk <br260@labyrinth.cl.cam.ac.uk>
Wed, 12 Nov 2003 17:00:46 +0000 (17:00 +0000)
add new domain 0 operation to read console ring in Xen

.rootkeys
BitKeeper/etc/logging_ok
tools/internal/Makefile
tools/internal/xi_read_console_ring.c [new file with mode: 0644]
xen/common/console.c [new file with mode: 0644]
xen/common/dom0_ops.c
xen/common/kernel.c
xen/include/hypervisor-ifs/dom0_ops.h
xen/include/xeno/console.h

index c6cb0d2d687001751dc71bd99cf367ea315a6ed6..b96338a42bd4f4711203d81b93f79ab2353a9a78 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3ec43c5dmQxGDvgJJXbV1yLxT30Y1A tools/internal/xi_helper
 3f108ad5wQm0ZaQ4GXFoUhH1W1aW9w tools/internal/xi_list.c
 3f0458aaXhD8BQAggO81gv30RQ-ifA tools/internal/xi_phys_grant.c
+3fb14ab76b0aJu66S18CVjlemLwk4Q tools/internal/xi_read_console_ring.c
 3fa9861aBdNV1yCjfY4cLPr4Mtrpuw tools/internal/xi_restore_linux.c
 3fa98615LWZfagwDBp7XfuC-u9wi3w tools/internal/xi_save_linux.c
 3f108adb2b5OkKL6-faG3lMiOYDf_w tools/internal/xi_sched_domain.c
 3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c
 3ddb79bddEYJbcURvqqcx99Yl2iAhQ xen/common/block.c
 3ddb79bdrqnW93GR9gZk1OJe1qK-iQ xen/common/brlock.c
+3fb10d07GscSWPKxBqpvNfU-dYfa0g xen/common/console.c
 3fa152581E5KhrAtqZef2Sr5NKTz4w xen/common/debug.c
 3ddb79bdLX_P6iB7ILiblRLWvebapg xen/common/dom0_ops.c
 3e6377e4i0c9GtKN65e99OtRbw3AZw xen/common/dom_mem_ops.c
index 673d59798e334fa4e237e4a1487480c73bfd6fde..7c732bc73cc4cd5a78dd594fc35c958c11dcee22 100644 (file)
@@ -6,6 +6,7 @@ akw27@labyrinth.cl.cam.ac.uk
 akw27@plucky.localdomain
 bd240@boulderdash.cl.cam.ac.uk
 bd240@labyrinth.cl.cam.ac.uk
+br260@labyrinth.cl.cam.ac.uk
 br260@laudney.cl.cam.ac.uk
 iap10@freefall.cl.cam.ac.uk
 iap10@labyrinth.cl.cam.ac.uk
index 3979cace5b6c2cf2383259be4c849dfaf93c1834..1a225c0d88b4230a987be0895c9783f89c7f4524 100644 (file)
@@ -11,6 +11,7 @@ TARGETS  = xi_create xi_start xi_stop xi_destroy xi_build
 TARGETS += xi_phys_grant xi_list xi_save_linux xi_restore_linux
 TARGETS += xi_sched_global xi_sched_domain xi_usage xi_vif_params
 TARGETS += xi_vbd_create xi_vbd_add xi_vbd_list xi_vbd_info 
+TARGETS += xi_read_console_ring
 INSTALL  = $(TARGETS) xi_vifinit xi_helper
 
 all: check-for-zlib $(TARGETS)
diff --git a/tools/internal/xi_read_console_ring.c b/tools/internal/xi_read_console_ring.c
new file mode 100644 (file)
index 0000000..9f28823
--- /dev/null
@@ -0,0 +1,47 @@
+/* 
+ * Usage: <executable> [-c]
+ */
+
+#include "dom0_defs.h"
+
+#define CONSOLE_RING_SIZE 16392
+static char *argv0 = "read_console_ring";
+
+static long read_console_ring(char *str, unsigned count)
+{
+    int ret;
+    dom0_op_t op;
+
+    op.cmd = DOM0_READCONSOLE;
+    op.u.readconsole.str = str;
+    op.u.readconsole.count = count;
+
+    ret = do_dom0_op(&op);
+    if (ret > 0) {
+        *(str + ret) = '\0';
+    }
+
+    return ret;
+}    
+
+int main(int argc, char **argv)
+{
+    char str[CONSOLE_RING_SIZE];
+
+    if ( argv[0] != NULL ) 
+        argv0 = argv[0];
+    
+    if ( argc > 2) {
+        fprintf(stderr, "Usage: %s [-r]\n", argv0);
+        return 1;
+    }
+    
+    if ( read_console_ring(str, CONSOLE_RING_SIZE) < 0 ) {
+       printf("Read console ring error.\n");
+       printf("%s", str);
+        return 1;
+    }
+
+    printf("%s", str);
+    return 0;
+}
diff --git a/xen/common/console.c b/xen/common/console.c
new file mode 100644 (file)
index 0000000..4836dc9
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * console.c
+ *
+ * read domain console output buffer ring in Xen 
+ *
+ */
+
+#include <xeno/console.h>
+#include <asm-i386/uaccess.h>
+
+void init_console_ring()
+{
+    console_ring.len = 0;
+}
+
+long read_console_ring(char *str, unsigned int count)
+{
+    unsigned int len;
+    
+    len = (console_ring.len < count)? console_ring.len : count;
+    
+    if ( copy_to_user(str, console_ring.buf, len) )
+        return -EFAULT;
+
+    return len;
+}
index b4f1bd54b9a713f2e6b35898e579a2e5429376e3..a1ac3a41dac83cf5d9092f237b897dba484a3746 100644 (file)
@@ -412,6 +412,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         ret = 0;
     }
     break;
+    
+    case DOM0_READCONSOLE:
+    {
+       extern long read_console_ring(char *, unsigned int);
+        ret = read_console_ring(op.u.readconsole.str, 
+                               op.u.readconsole.count); 
+    }
+    break;    
 
     default:
         ret = -ENOSYS;
index 6db936a3d7b1ecd2892d4f089e606a73ad7ef825..8e2b7a7d4979ed01aadb4c15ecf7d1d3b397f766 100644 (file)
@@ -156,6 +156,7 @@ void cmain (unsigned long magic, multiboot_info_t *mbi)
     }
 
     init_serial();
+    init_console_ring();
     init_vga();
     cls();
 
@@ -447,12 +448,27 @@ void putchar_console(int c) {}
 
 #endif
 
+#ifdef CONFIG_OUTPUT_CONSOLE_RING
+
+void putchar_console_ring(int c)
+{
+    if (console_ring.len < CONSOLE_RING_SIZE)
+        console_ring.buf[console_ring.len++] = (char)c;
+}
+
+#else
+
+void putchar_console_ring(int c) {}
+
+#endif
+
 
 static void putchar(int c)
 {
     if ( (c != '\n') && ((c < 32) || (c > 126)) ) return;
     putchar_serial(c);
     putchar_console(c);
+    putchar_console_ring(c);
 }
 
 
index 7c0624b1d2bae12d6e7ae695257449a0f1c23b20..134eb82ddf6ace13a8dbb957a776bde5351af0f6 100644 (file)
@@ -185,6 +185,17 @@ typedef struct dom0_settime_st
     u64 system_time;
 } dom0_settime_t;
 
+/*
+ * Read console content from Xen buffer ring.
+ */
+
+#define DOM0_READCONSOLE      19
+typedef struct dom0_readconsole_st
+{
+    char *str;
+    unsigned int count;
+} dom0_readconsole_t;
+
 typedef struct dom0_op_st
 {
     unsigned long cmd;
@@ -205,6 +216,7 @@ typedef struct dom0_op_st
        dom0_msr_t              msr;
        dom0_debug_t            debug;
        dom0_settime_t          settime;
+       dom0_readconsole_t      readconsole;
     } u;
 } dom0_op_t;
 
index 9d61754ae8129a6d43ac9ece204990b7ffec1395..aff48143822eb209677cc8213c43016f25aa8406 100644 (file)
  * yet, so this will do for now.
  */
 
-#define CONFIG_OUTPUT_CONSOLE 1
 #define CONFIG_OUTPUT_SERIAL  1
+#define CONFIG_OUTPUT_CONSOLE 1
+#define CONFIG_OUTPUT_CONSOLE_RING 1
 
 extern int opt_console;
+
+#define CONSOLE_RING_SIZE     16392
+
+typedef struct console_ring_st
+{
+    char buf[CONSOLE_RING_SIZE];
+    unsigned int len;
+} console_ring_t;
+
+console_ring_t console_ring;
+
+void init_console_ring();
+long read_console_ring(char *str, unsigned int count);